﻿singleApp.service('AppDataService', ['$http', function ($http) {

    this.StatusList = [
        { value: '0', label: '草稿' },
        { value: '1', label: '上线' },
    ];

    this.SexList = [
        { value: '', label: '-- Select ---' },
        { value: 'male', label: 'Male' },
        { value: 'female', label: 'Female' },
    ];

    this.TimePeriodList = [
        [{ value: 1, label: "00:00-00:30", check: false }, { value: 2, label: "00:30-01:00", check: false }, { value: 3, label: "01:00-01:30", check: false }, { value: 4, label: "01:30-02:00", check: false }, { value: 5, label: "02:00-02:30", check: false }, { value: 6, label: "02:30-03:00", check: false }],
        [{ value: 7, label: "03:00-03:30", check: false }, { value: 8, label: "03:30-04:00", check: false }, { value: 9, label: "04:00-04:30", check: false }, { value: 10, label: "04:30-05:00", check: false }, { value: 11, label: "05:00-05:30", check: false }, { value: 12, label: "05:30-06:00", check: false }],
        [{ value: 13, label: "06:00-06:30", check: false }, { value: 14, label: "06:30-07:00", check: false }, { value: 15, label: "07:00-07:30", check: false }, { value: 16, label: "07:30-08:00", check: false }, { value: 17, label: "08:00-08:30", check: false }, { value: 18, label: "08:30-09:00", check: false }],
        [{ value: 19, label: "09:00-09:30", check: false }, { value: 20, label: "09:30-10:00", check: false }, { value: 21, label: "10:00-10:30", check: false }, { value: 22, label: "10:30-11:00", check: false }, { value: 23, label: "11:00-11:30", check: false }, { value: 24, label: "11:30-12:00", check: false }],
        [{ value: 25, label: "12:00-12:30", check: false }, { value: 26, label: "12:30-13:00", check: false }, { value: 27, label: "13:00-13:30", check: false }, { value: 28, label: "13:30-14:00", check: false }, { value: 29, label: "14:00-14:30", check: false }, { value: 30, label: "14:30-15:00", check: false }],
        [{ value: 31, label: "15:00-15:30", check: false }, { value: 32, label: "15:30-16:00", check: false }, { value: 33, label: "16:00-16:30", check: false }, { value: 34, label: "16:30-17:00", check: false }, { value: 35, label: "17:00-17:30", check: false }, { value: 36, label: "17:30-18:00", check: false }],
        [{ value: 37, label: "18:00-18:30", check: false }, { value: 38, label: "18:30-19:00", check: false }, { value: 39, label: "19:00-19:30", check: false }, { value: 40, label: "19:30-20:00", check: false }, { value: 41, label: "20:00-20:30", check: false }, { value: 42, label: "20:30-21:00", check: false }],
        [{ value: 43, label: "21:00-21:30", check: false }, { value: 44, label: "21:30-22:00", check: false }, { value: 45, label: "22:00-22:30", check: false }, { value: 46, label: "22:30-23:00", check: false }, { value: 47, label: "23:00-23:30", check: false }, { value: 48, label: "23:30-24:00", check: false }]
    ];

}]);


singleApp.service("FileUpload", ['Upload', function (Upload) {
    this.upload = function (file, action) {
        return Upload.upload({
            url: window.singleConfig.rootUrl + "api/common/FileService/" + action,
            method: "POST",
            file: file,
            //withCredentials: true,
            headers: {}
        });
    };
}]);

singleApp.service('PageService', ['$http', function ($http) {

    this.getPageRange = function (pageindex, pagewindowsize, totalpages) {
        var pagerange = [];
        var pagewindowstart = (Math.ceil(pageindex / pagewindowsize) - 1) * pagewindowsize + 1;
        var pagewindowend = pagewindowstart + pagewindowsize - 1;
        if (pagewindowend > totalpages) {
            pagewindowend = totalpages;
        }
        for (var i = pagewindowstart; i <= pagewindowend; i++) {
            pagerange.push(i);
        }
        return pagerange;
    };

}]);

singleApp.service('Session', ['$http', function ($http) {
    /**
     * get category from server when angular app start
     */
    //this.initCategory = function () {
    //    if (typeof localStorage.session == 'undefined') {
    //        var category_url = window.singleConfig.rootUrl + "api/users/CategoryService/getAll";
    //        $http.get(category_url).success(function (data) {
    //            localStorage.setItem('session', JSON.stringify(data.data));
    //        });
    //    }
    //};

    /**
     * read category at other pages
     */
    //this.readCategory = function () {
    //    if (typeof localStorage.session != 'undefined') {
    //        var categories = JSON.parse(localStorage.session);
    //        return categories;
    //    }
    //    else{
    //        return null;
    //    }
    //};
}]);

//singleApp.run(['Session', function (Session) {
//    Session.initCategory();
//}]);